package top.oylan.manager.controller.home;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;

/**
 * Created by A on 2019/2/15.
 */
@Component
public class OylanRedisComponent {

    @Autowired
    StringRedisTemplate redisTemplate;

    public void set(String key,String value){
        ValueOperations<String, String> ops = redisTemplate.opsForValue();
        if(!redisTemplate.hasKey(key)){
            ops.set(key,value);
            System.out.println("set success");
        }else{
            System.out.println("get "+ops.get(key));
        }
    }

    public String get(String key){
        return this.redisTemplate.opsForValue().get(key);
    }
}
